package com.example.project.projectspringcloud.controller.admin.comment;

import com.example.project.projectspringcloud.entity.Page;
import com.example.project.projectspringcloud.entity.user.Comment;
import com.example.project.projectspringcloud.service.user.UserCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Api(tags = "后台评论管理")
@Controller
@RequestMapping(value = "/admin/comment")
public class AdminCommentController {

    @Autowired
    private UserCommentService commentService;

    @ApiOperation(value = "评论管理列表", notes = "返回评论管理列表")
    @GetMapping(value = {"", "/list"})
    public String list(Comment comment, Page page, Model model) {
        List<Comment> comments = commentService.list(page, comment);
        model.addAttribute("page", new Page<Comment>(comments));
        model.addAttribute("comment", comment);
        return "admin/comment/comment-list";
    }
}
